﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using CocisDBUtility;
using CocisModel;

namespace CocisDAL
{
    public class LoginDAL
    {
       
       

        #region 判断原密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="login"></param>
        /// <param name="id"></param>
        /// <param name="paswd"></param>
        /// <returns></returns>
        public int CheckPassword(int userId, string paswd)
        {
            string sql = " select count(*) from  UserInfo  where pwd='" + paswd + "' and userId='" + userId + "' ";
              
            int i = 0;
            SqlDataReader sdr = SQLHelper.ExecuteReader(SQLHelper.ConStr, CommandType.Text, sql, null);
            if (sdr.Read())
            {
                i = int.Parse(sdr[0].ToString());
            }

            return i;

        }


        #endregion


        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="login"></param>
        /// <param name="id"></param>
        /// <param name="paswd"></param>
        /// <returns></returns>
        public int UpdatePassword(int userId,string paswd)
        {
            string sql = " update UserInfo  set pwd='" + paswd + "' where userId='" + userId + "' ";
 
           
            return SQLHelper.ExecuteNonQuery(SQLHelper.ConStr, CommandType.Text, sql, null);

        }

        #endregion


    }
}
